package cn.green.components.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class AuthenticationController {

    @PostMapping("loginSuccess")
    public String loginSuccess() {
        return "mainPage";
    }

    /**
     * 登录失败跳转页面
     * @return
     */
    @GetMapping("loginError")
    public String loginError() {
        return "loginError";
    }

    @GetMapping("simpleLogout")
    public String logout(HttpServletRequest request) {
        //使用户会话失效
        System.out.println("执行注销逻辑");
        request.getSession().invalidate();
        return "logout";
    }

}
